home *** CD-ROM | disk | FTP | other *** search
- /* Cruise.c */
-
- /*
- Project Info -> Code Resource, file creator 'rsed', type 'rsrc'
- Type: 'COOL'
- Custom Header option on ( VERY IMPORTANT! )
- Attributes: 00
-
- Compile into file called 'Init.π.rsrc' to be
- incorporated into the init half of the program.
-
- Use ResEdit to add a 'sysz' resource with the
- following data:
-
- 00: 0000 010C
-
- This is the amount of system heap that I need
- to install everything.
- */
-
- #include "Cruise.h"
-
- main()
- {
- asm
- {
- MyBlockPtr:
- dc.l 0
-
- Entry:
- lea @MyBlockPtr,a0
- move.l (a0),a0 /* Get Globals address */
-
- move.l d1,-(sp) /* save d1 */
-
- tst.b CrsrCouple /* make sure coupling is on before we do things */
- beq @Exit
-
-
- move.w MTemp.h,d0 /* Get Delta horizontal */
- sub.w RawMouse.h,d0
- add.w OFFSET(crsrTaskVars,Velh)(a0),d0 /* add to vel.h */
- move.w d0,OFFSET(crsrTaskVars,Velh)(a0)
- add.w OFFSET(crsrTaskVars,Prevh)(a0),d0 /* add vel to position */
- move.w d0,d1 /* save a floating position */
- asr.w #3,d0 /* truncate to an integer */
- move.w d0,RawMouse.h /* move the mouse there */
-
- /*
- * The next bit is a tad weird. If the mouse hits the edge of
- * the screen, the Velv &Velh variables need to be limited.
- * The easiest way to check for boundries is when the cursor
- * hasn't moved inspite of our attempts to move it.
- */
- move.w Mouse.h,d0
- cmp.w OFFSET(crsrTaskVars,PrevInth)(a0),d0
- beq.s @1 /* we're not moving, don't update tickcounter */
-
- move.l Ticks,OFFSET(crsrTaskVars,LastTimeh)(a0)
- move.w d0,OFFSET(crsrTaskVars,PrevInth)(a0)
-
- @1
- move.w d1,OFFSET(crsrTaskVars,Prevh)(a0) /* remember for next pass */
-
- /*
- * Now really test to see if the cursor is moving. If 9
- * ticks have elapsed since last movement, assume we've hit the
- * wall and therefore should clip the velocity and re-sync the
- * position.
- */
- move.l OFFSET(crsrTaskVars,LastTimeh)(a0),d0
- sub.l Ticks,d0
- cmp.w #-9,d0
- bge.s @3
-
- move.l Ticks,OFFSET(crsrTaskVars,LastTimeh)(a0)
- clr.w OFFSET(crsrTaskVars,Velh)(a0) /* zero vel */
- move.w Mouse.h,d0
- move.w d0,OFFSET(crsrTaskVars,PrevInth)(a0) /* sync int pos */
- asl.w #3,d0
- move.w d0,OFFSET(crsrTaskVars,Prevh)(a0) /* sync float pos */
-
- @3
- /*
- * now do the same thing for the vertical coordinates.
- */
- move.w MTemp.v,d0
- sub.w RawMouse.v,d0
- add.w OFFSET(crsrTaskVars,Velv)(a0),d0
- move.w d0,OFFSET(crsrTaskVars,Velv)(a0)
- add.w OFFSET(crsrTaskVars,Prevv)(a0),d0
- move.w d0,d1
- asr.w #3,d0
- move.w d0,RawMouse.v
-
- move.w Mouse.v,d0
- cmp.w OFFSET(crsrTaskVars,PrevIntv)(a0),d0
- beq.s @2
-
- move.l Ticks,OFFSET(crsrTaskVars,LastTimev)(a0)
- move.w d0,OFFSET(crsrTaskVars,PrevIntv)(a0)
-
- @2
- move.w d1,OFFSET(crsrTaskVars,Prevv)(a0) /* remember for next pass */
-
- move.l OFFSET(crsrTaskVars,LastTimev)(a0),d0
- sub.l Ticks,d0
- cmp.w #-9,d0
- bge.s @4
-
- move.l Ticks,OFFSET(crsrTaskVars,LastTimev)(a0)
- clr.w OFFSET(crsrTaskVars,Velv)(a0) /* zero vel */
- move.w Mouse.v,d0
- move.w d0,OFFSET(crsrTaskVars,PrevIntv)(a0) /* sync int pos */
- asl.w #3,d0
- move.w d0,OFFSET(crsrTaskVars,Prevv)(a0) /* sync float pos */
-
- @4
-
- /*
- * The setting of CrsrNew effects Obscuring the cursor. If CrsrNew
- * is always forced high, then the cursor will not dissapear while
- * you're typing.
- */
- move.l RawMouse,d0 /* Get 'old' */
- cmp.l MTemp,d0 /* Same as 'new'? */
- beq.s @Exit
- move.l d0,MTemp /* Nope, move it */
- move.b #0xFF,CrsrNew
-
- /*
- * Notice that MTemp=RawMouse. This is done to avoid having the
- * real jCrsrTask from extracting Delta info as I did and then
- * scaling the results up.
- */
-
- Exit:
- move.l (sp)+,d1
- move.l OFFSET(crsrTaskVars,OldCrsrTask)(a0),a0
- /* get original routine */
- jmp (a0) /* go there */
- }
- }
-